package com.ysx.service;

import com.ysx.pojo.Items.Items;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @PROJECT_NAME: shopping-demo
 * @DESCRIPTION:
 * @USER: yyy
 * @DATE: 2021/11/1 23:14
 */
public class service_test {


    @Test
    public void test2() {
        ApplicationContext con = new ClassPathXmlApplicationContext("spring-service.xml");

        ItemsService bean = con.getBean(ItemsService.class);

        //查询
        for (Items item : bean.getItems()) {
            System.out.println("item = " + item);
        }

        //新增
        Items items = new Items();
        items.setName("ss");
        int add = bean.add(items);
        if (add > 0) {
            System.out.println("\"添加成功\" = " + "添加成功");
        }

    }
}
